package com.fifth.commodity.controller.api;

import com.fifth.commodity.service.GoodsService;
import com.fifth.common.pojo.entity.ZoneBusiness;
import com.fifth.common.pojo.vo.SelectBusinessInfoByGNameVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("api/goods")
public class ApiGoodsController {
    @Autowired
    private GoodsService goodsService;

    /*
    * 商品描述
    * */
    @GetMapping("goodsbyid/{id}")
    public String goodsById(@PathVariable String id){
        String goodsid = goodsService.goodsid(id);
        return goodsid;

    }
    /*
    * 商品名称
    * */
    @GetMapping("goodsbyidname/{id}")
    public String goodsByIdName(@PathVariable String id){
        String goodsname = goodsService.goodsidname(id);
        return goodsname;
    }

    /**
     * 模糊查询商品名查询对应店铺信息
     * @param name
     * @return
     */
    @PostMapping("findBusinessByGName/{name}")
    public List<ZoneBusiness> findBusinessByGName(@PathVariable String name){
        System.out.println(name);
        return  goodsService.findBusinessByGName(name);
    }

    /**
     * 检查商品上下架状态
     * @param goodsid
     * @return
     */
    @GetMapping("checkGoodsStatus/{goodsid}")
    public Integer checkGoodsStatus(@PathVariable String goodsid){
        return goodsService.checkGoodsStatus(goodsid);
    }
}
